package com.stylefeng.guns.modular.system.controller.server;

import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.common.annotion.Permission;
import com.stylefeng.guns.common.constant.Const;
import com.stylefeng.guns.common.constant.factory.PageFactory;
import com.stylefeng.guns.common.persistence.model.Member;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.modular.system.dao.MemberDao;
import com.stylefeng.guns.modular.system.warpper.MemberWarpper;
import com.stylefeng.guns.modular.system.warpper.NoticeWrapper;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author lmshe
 * @create 2017-11-08 11:03
 * @desc
 */
@Controller
@RequestMapping("/member")
public class MemberController extends BaseController{

    private static String PREFIX = "/system/member/";

    @Resource
    private MemberDao memberDao;

    /**
     * 跳转到会员管理页面
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "member.html";
    }
    /**
     * @author lmshe
     * @create 11:20 2017/11/8
     * @desc 查询会员列表
     */
    @RequestMapping("/list")
    @ResponseBody
    public Object list(@RequestParam(required = false) String name,@RequestParam(required = false) String accountMobile) {
        Page<Member> page = new PageFactory<Member>().defaultPage();
        List<Map<String, Object>> result = memberDao.getMemberList(page, name,accountMobile,page.getOrderByField(), page.isAsc());
        page.setRecords((List<Member>) new MemberWarpper(result).warp());
        return super.packForBT(page);
    }
}
